{% extends 'base.html' %}
{% load i18n %}
{% load render_bundle from webpack_loader %}

{% block title %}
  {{ page_title }} | {% firstof site.name platform_name %}
{% endblock %}

{% block content %}
  <div class="certificate">
    <div class="wrapper-view" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">

      {% block header %}
        {% include child_templates.header %}
      {% endblock %}

      {% if user.is_staff or user.is_authenticated and user.username == user_data.username %}
        {% block sharing %}
          <div class="wrapper-banner wrapper-banner-user">
            <section class="banner banner-user">
              <div class="message message-block message-notice">
                <div class="message-text">
                  <h2 class="message-title">
                    {% blocktrans with user_name=user_data.name trimmed %}
                      Congratulations, {{ user_name }}!
                    {% endblocktrans %}
                  </h2>

                  <p class="message-copy">
                    {% blocktrans trimmed %}
                      You worked hard to earn your certificate from {{ platform_name }} — share it with colleagues,
                      friends, and family to get the word out about what you mastered in {{ program_name }}.
                    {% endblocktrans %}
                  </p>
                </div>
                {% include '_actions.html' %}
              </div>
            </section>
          </div>
        {% endblock %}
      {% endif %}

      {% block certificate %}
        {% include child_templates.credential %}
      {% endblock %}

      {% block certificate_metadata %}
      {% endblock %}

      {% block footer %}
        {% include child_templates.footer %}
      {% endblock %}
    </div>
  </div>
{% endblock %}

{% block javascript %}
  {{ block.super }}

  {% if enable_facebook_sharing %}
    <script type="application/javascript">
        window.edx.facebook = {
            enabled: {{ enable_facebook_sharing|yesno:"true,false" }},
            appId: '{{ facebook_app_id|escapejs }}',
            href: '{{ share_url|escapejs }}'
        };
    </script>

    {# NOTE (CCB): This currently only deals with Facebook. #}
    {# If this script changes, move this call outside of the conditional. #}
    {% render_bundle 'sharing' 'js' %}
    <script id="facebook-jssdk" src="https://connect.facebook.net/en_US/sdk.js"></script>
  {% endif %}
{% endblock %}
